package com.ym.b2b.payment.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.payment.dao.EmSPaymentDAO;
import com.ym.b2b.payment.sqlbean.EmSPayment;
import com.zc.commons.base.Page;

@Repository
public class EmSPaymentDAOImpl<T> extends BaseDao<T> implements EmSPaymentDAO {

    public Long searchPageEmSPaymentNum(EmSPayment emspayment) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emspayment);
        return (Long) listNum("EM_S_PAYMENT.searchPageEmSPaymentNum", map);
    }

    public Page searchPageEmSPayment(EmSPayment emspayment, Page<EmSPayment> page) throws DataAccessException {
        page.setTotalRow(searchPageEmSPaymentNum(emspayment));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", emspayment);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_S_PAYMENT.searchPageEmSPayment", map));
        return page;
    }

    public void insertEmSPayment(EmSPayment record) throws DataAccessException {
        insert("EM_S_PAYMENT.insertEmSPayment", record);
    }

    public int updateEmSPayment(EmSPayment record) throws DataAccessException {
        int rows = update("EM_S_PAYMENT.updateEmSPayment", record);
        return rows;
    }

    public EmSPayment searchEmSPayment(EmSPayment emspayment) throws DataAccessException {
        EmSPayment record = (EmSPayment) find("EM_S_PAYMENT.searchEmSPayment", emspayment);
        return record;
    }

    public int deleteEmSPayment(Long paymentId) throws DataAccessException {
        EmSPayment key = new EmSPayment();
        key.setPaymentId(paymentId);
        int rows = delete("EM_S_PAYMENT.deleteEmSPayment", key);
        return rows;
    }
}
